/*
Christopher Raffaele
02/18/2010
CSC280
Assignement 2 Towers of Hanoi

HanoiGame.h
*/
#pragma once

#include<string>
#include<iostream>
#include"Tower.h"

///Class to handle the funcionality needed in the game
class HanoiGame{
private:
	//the move list when auto-solving
	std::string tempmsg;
protected:
	//towers/pegs
	Tower* towerA;
	Tower* towerB;
	Tower* towerC;

	//number of starting disks
	unsigned int totalDisks;
	bool finished;

	//number of moves taken to complete
	unsigned int moves;

	//for showing the description of last move 
	std::string lastMove;

public:
	/// <summary>
	/// Creates a tower game, initializing tower a with the number of disks passed
	/// </summary>
	/// <param name="numDisks">The number of disks in the game.</param>
	HanoiGame(unsigned int numDisks);

	/// <summary>
	/// Cleans up dynamically allocated tower memory
	/// </summary>
	~HanoiGame();

	/// <summary>
	/// Returns a bool as to whether the game is finished
	/// </summary>
	bool Finished(){
		return finished;
	}

	/// <summary>
	/// Recursive algorithm to solve the towers of hanoi problem
	/// </summary>
	/// <param name="numDisks">The number of the disks to move.</param>
	/// <param name="fromTower">The tower moving from.</param>
	/// <param name="toTower">The tower moving to.</param>
	/// <param name="openTower">The open tower.</param>
	void Solve(unsigned int numDisks, char fromTower, char toTower, char openTower);

	/// <summary>
	/// Move the top value from a tower to the top of another tower. Ensures
	/// only valid moves.
	/// </summary>
	/// <param name="fromTower">The tower the top value will be moved from.</param>
	/// <param name="toTower">The tower the value will be moving to.</param>
	void Swap(const char fromTower, const char toTower);

	/// <summary>
	/// So the game can be used with cout
	/// </summary>
	/// <param name="numDisks">The ostream reference.</param>
	/// <param name="aHanoiGame">A HanoiGame object.</param>
	friend std::ostream& operator<<(std::ostream& os, const HanoiGame& aHanoiGame);
};
